package offer;

/**
 * @Author SSK
 * @Date Created in 18:32 2019/8/4
 * @Description 扑克牌顺子
 * @Version 1.0
 */
public class T46 {
    public boolean isContinuous(int [] numbers) {
        if (numbers.length!=5) return false;
        int num[] = new int[14];
        for (int i = 0; i < numbers.length; i++) {
            num[numbers[i]]++;
        }
        int i = 1;
        while (num[i]==0) {
            i++;
        }
        for (int j = i; j < Math.min( 14 ,i + 5); j++) {
            if (num[j]==0) {
                num[0]--;
                if (num[0]<0) {
                    return false;
                }
            }else if(num[j]>1) {
                return false;
            }
        }
        return true;
    }
}
